<?php

/**
 * Created by PhpStorm.
 * User: hc
 * Date: 16/8/16
 * Time: 上午9:29
 */
namespace Common\Controller;


use Think\Controller\RestController;
class ApiAuthController extends RestController
{
    //这里可以写一些权限验证之类的逻辑
    protected function _initialize()
    {

    }

    /**
     * 接口返回正确格式
     */
    protected function onOk($data = '',$type='json',$status='200')
    {
        $result = ['status' => $status, 'errmsg' => '成功', 'data' => $data];
        $this->ajaxReturn($result,$type);
    }

    /**
     * @param $errmsg
     * @param int $errno
     * 接口返回错误格式
     */
    protected function onError($errmsg, $status = '400')
    {
        $result = ['status' => $status, 'errmsg' => $errmsg];
        $this->ajaxReturn($result);
    }
}